import React from "react";

import { useDelete } from "./useDelete";
import { useForm } from "./useForm";
import { AuthEdit, AuthDelete } from "../../../components/AuthArea";

export const useColumns = () => {
  const { handleDelete } = useDelete();
  const { handleEdit } = useForm();

  const columns = [
    {
      title: "角色描述",
      dataIndex: "description",
      key: "description",
      sorter: true
    },
    {
      title: "角色名称",
      dataIndex: "name",
      key: "name",
      sorter: true
    },
    {
      title: "创建时间",
      dataIndex: "dateCreated",
      key: "dateCreated",
      sorter: true
    },
    {
      title: "更新时间",
      dataIndex: "dateUpdated",
      key: "dateUpdated",
      sorter: true,
      defaultSortOrder: "descend"
    },
    {
      title: "操作",
      key: "action",
      render: (text, record) => (
        <span>
          <AuthEdit
            auth="AUTH_SYS_ROLE_UPDATE"
            record={record}
            handleEdit={handleEdit}
          />
          <AuthDelete
            auth="AUTH_SYS_ROLE_DELETE"
            record={record}
            handleDelete={handleDelete}
          />
        </span>
      )
    }
  ];

  return {
    columns
  };
};
